package com.until;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import com.alibaba.druid.pool.DruidDataSource;

<<<<<<< HEAD
/**
 * �������ӳ�
 * @author z'y'l
 *
 */
=======

>>>>>>> branch 'master' of https://gitee.com/lulu03/zyl-wed.git

public class AliPool {
	static DruidDataSource ds;
<<<<<<< HEAD
=======
	
>>>>>>> branch 'master' of https://gitee.com/lulu03/zyl-wed.git
	static {
		String fname = "druid.properties";
		InputStream file = AliPool.class.getClassLoader().getResourceAsStream(fname);
		Properties prop = new Properties();
		try {
			prop.load(file);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
<<<<<<< HEAD
=======
		
>>>>>>> branch 'master' of https://gitee.com/lulu03/zyl-wed.git
		String driver = prop.getProperty("driver");
		String url = prop.getProperty("url");
		String name = prop.getProperty("username");
		String pass = prop.getProperty("password");
		String init = prop.getProperty("initialSize");
		String min = prop.getProperty("minIdle");
		String max = prop.getProperty("maxActive");
		String Wait = prop.getProperty("maxWait");
		
		System.out.println(driver);
		System.out.println(url);
		System.out.println(name);
		System.out.println(pass);
		System.out.println(init);
		System.out.println(min);
		System.out.println(max);
		System.out.println(Wait);
		
<<<<<<< HEAD
	
=======
		
>>>>>>> branch 'master' of https://gitee.com/lulu03/zyl-wed.git
		ds = new DruidDataSource();
		ds.setDriverClassName(driver);
		ds.setUrl(url);
		ds.setUsername(name);
		ds.setPassword(pass);
		ds.setInitialSize(new Integer(init));
		ds.setMinIdle(new Integer(min));
		ds.setMaxActive(new Integer(max));
		ds.setMaxWait(new Long(Wait));	
	}
<<<<<<< HEAD

=======
	
>>>>>>> branch 'master' of https://gitee.com/lulu03/zyl-wed.git
	public static Connection getConn() {
		Connection conn = null;
		try {
			conn = ds.getConnection();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return conn;
		
	}
	
	public static void main(String[] args) {
		
		System.out.println(AliPool.getConn());
	}
}
